package com.dragonfly.shutter.controllers;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.imageio.ImageReader;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.bind.support.SessionStatus;
import org.springframework.web.servlet.ModelAndView;

import com.dragonfly.shutter.DAOIbatisImpls.AlbumDAOIbatisImpl;
import com.dragonfly.shutter.DAOIbatisImpls.PictureDAOIbatisImpl;
import com.dragonfly.shutter.DAOIbatisImpls.UserDAOIbatisImpl;
import com.dragonfly.shutter.beans.Album;
import com.dragonfly.shutter.beans.UserLogin;
import com.dragonfly.shutter.validator.AlbumValidator;
import com.dragonfly.shutter.validator.LoginValidator;

/**
 * 用户登录的控制器
 * @author 王长乐
 *
 */
@Controller
@SessionAttributes("userID")
public class MergeAlbumController {
	@Autowired
	private UserDAOIbatisImpl userDAO;
	
	@RequestMapping(value="/mergeAlbumList.html",method = RequestMethod.GET)
	public String onLoad(ModelMap model,SessionStatus status,
			             @ModelAttribute("userID")Integer userID)
	{
        if(userID==null)
        	return "login";
        else
        	
		return "mergeAlbumList";

	}

	@RequestMapping(value="/mergeAlbumList.html",method = RequestMethod.POST)
	public String processSubmit(ModelMap model,
			        @ModelAttribute("userID")Integer userID, BindingResult result,
	                   SessionStatus status)
	{
	       List<Album> albumList=new ArrayList<Album>(); //@TODO:得到要合并的相册；
	       
	       if(albumList.size()==0)
	    	   return "mergeAlbumList";
	return "s";

		  /*
	    	   new LoginValidator().validate(userLogin, result);
			
			if(result.hasErrors())
			{
			        return new ModelAndView("login");
			}
			else
			{
				UserLogin UId=userDAO.selectLoginInfoByEmail(userLogin.getEmail());//@TODO：通过邮箱得到用户ID
				
				model.addAttribute("userID", UId.getUserID());
				
				return new ModelAndView("index.html");
				
			}
	       */
	}
			
		}
		
	

	

